package xin.marcher.module.construction.strategy.status;

import org.springframework.stereotype.Service;
import xin.marcher.module.construction.domain.entity.ItemInfoDO;
import xin.marcher.module.construction.domain.request.ProductStatusRequest;
import xin.marcher.module.construction.repository.ProductInfoRepository;
import xin.marcher.module.construction.repository.ProductStatusRepository;
import xin.marcher.module.construction.strategy.route.AbstractStatusStrategy;

import javax.annotation.Resource;

/**
 * 下架状态变更
 *
 * 
 */
@Service
public class OffShelvesStatusService extends AbstractStatusStrategy {

    @Resource
    private ProductStatusRepository productStatusRepository;

    @Resource
    private ProductInfoRepository productInfoRepository;

    /**
     * 上架状态 变更到下架状态
     * 预上架状态 变更到下架状态
     *
     * @param productStatusRequest
     */
    @Override
    public void updateProductStatus(ProductStatusRequest productStatusRequest) {
        //1.查询商品信息
        ItemInfoDO itemInfoDO = productInfoRepository.getItemByItemId(productStatusRequest.getItemId());

        //2.商品状态变更
        productStatusRepository.updateProductStatus(itemInfoDO, productStatusRequest.getItemStatus());
    }


}
